package com.zhx.common.chat;

import cn.hutool.core.util.ReUtil;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.IOException;
import java.util.List;
import java.util.regex.Pattern;

public class testUrl {
    /**
     * 验证正则表达式
     * @param args
     */
//    public static void main(String[] args) {
//        String content = "这是一个很长的字符串再来 www.github.com，其中包含一个URL www.baidu.com,, 一个带有端口号的URL http://www.jd.com:80, 一个带有路径的URL http://mallchat.cn, 还有美团技术文章https://mp.weixin.qq.com/s/hwTf4bDck9_tlFpgVDeIKg";
//        // 正则表达式
//        Pattern pattern = Pattern.compile("((http|https)://)?(www.)?([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\w@?^=%&/~+#-])?");
//        List<String> matchList = ReUtil.findAll(pattern, content, 0);//hutool工具类
//        System.out.println(matchList);
//    }
    public static void main(String[] args) throws IOException {
        Connection connect = Jsoup.connect("http://www.baidu.com");
        Document document = connect.get();
        String title = document.title();
        System.out.println(title);

//        Connection connect = Jsoup.connect("https://mp.weixin.qq.com/s/O4Ts0UnnDlYB5OQyCxO0Og");
//        Document document = connect.get();
//        String title = document.getElementsByAttributeValue("property", "og:title").attr("content");
//        System.out.println(title);

//        Connection connect = Jsoup.connect("https://www.bilibili.com/?spm_id_from=333.337.0.0");
//        Document document = connect.get();
//        String title = document.title();
//        String attr = document.getElementsByAttributeValue("rel", "shortcut icon").attr("href");
//        System.out.println(title);
//        System.out.println(attr);


    }


}
